package ${config.basePackage}.${artifact.relatedPackage};

import ${config.basePackage}.dao.${materialDetail.material.domainName}Dao;
import ${config.basePackage}.domain.${materialDetail.material.domainName};
import ${config.basePackage}.service.${materialDetail.material.domainName}Service;
import org.jaronsource.framework.core.dao.support.PageRequest;
import org.jaronsource.framework.core.dao.support.Criteria;
import org.jaronsource.framework.core.dao.support.Page;
import org.jaronsource.framework.core.service.SearchForm;
import org.jaronsource.framework.core.service.SearchFormSupportGenericService;
import org.springframework.beans.factory.annotation.Autowired;
import org.jaronsource.framework.core.dao.support.IGenericDao;
import org.jaronsource.framework.core.dao.support.ICommonDao;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Service;

@Service
public class ${materialDetail.material.domainName}ServiceImpl extends SearchFormSupportGenericService<${materialDetail.material.domainName}, ${materialDetail.pk.propertyType}> implements ${materialDetail.material.domainName}Service {

	@Autowired
	private ${materialDetail.material.domainName}Dao ${materialDetail.material.domainName?uncap_first}Dao;
	
	@SuppressWarnings( "unused" )
	@Autowired
	private ICommonDao commonDao;
	
	@Override
	public IGenericDao<${materialDetail.material.domainName}, ${materialDetail.pk.propertyType}> getDao() {
		return ${materialDetail.material.domainName?uncap_first}Dao;
	}
	
	@Override
	@Transactional
	public ${materialDetail.material.domainName} save(${materialDetail.material.domainName} ${materialDetail.material.domainName?uncap_first}) {
		return getDao().save(${materialDetail.material.domainName?uncap_first});
	}
	
	@Override
	@Transactional
	public void remove(${materialDetail.pk.propertyType} pk) {
		getDao().remove(pk);
	}
	
	@Override
	public Page<${materialDetail.material.domainName}> findPage( SearchForm searchForm ) {
		
		Criteria criteria = parseForm( searchForm );
		PageRequest pageRequest = searchForm.getPageRequest();
		
		return getDao().findPage( pageRequest, criteria );
	}

}